package file;

import java.io.File;
import java.io.FileFilter;

/**
 * 获取file包中大小超过500字节的所有子项
 */
public class Test3 {
    public static void main(String[] args) {
        File dir = new File("./src/file");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(new FileFilter() {
                public boolean accept(File file) {
                    return file.length()>500;
                }
            });
            for (int i=0;i<subs.length;i++){
                System.out.println(subs[i].getName()+";"+subs[i].length()+"字节");
            }
        }

        /*FileFilter filter = new FileFilter() {
            public boolean accept(File file) {
                return file.length()>500;
            }
        };
        File dir = new File("./src/file");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(filter);
            for (int i=0;i< subs.length;i++){
                System.out.println(subs[i].getName()+":"+subs[i].length());
            }
        }*/
    }
}
